package heuristicFunctions;

import aima.core.search.framework.HeuristicFunction;
import aima.core.util.datastructure.XYLocation;
import domain.PacmanBoard;

public class EuclidianDistance implements HeuristicFunction {
	@Override
    public double h(Object state)
    {
        final PacmanBoard board = (PacmanBoard) state;
        final XYLocation actor = board.getPacmanLocation();
        final XYLocation finish = board.getFinishLocation();
        if(finish != null)
        	return Math.sqrt(Math.pow(actor.getXCoOrdinate() - finish.getXCoOrdinate(), 2) + Math.pow(actor.getYCoOrdinate() - finish.getYCoOrdinate(), 2));
        return 0;
    }
}
